home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / Sample.bin / TreeViewApplet.java < prev    next >
Text File  |  1998-11-01  |  30KB  |  669 lines

  1. /*
  2.     A basic extension of the java.applet.Applet class
  3. */
  4.  
  5. import java.awt.*;
  6. import java.applet.*;
  7. import symantec.itools.awt.TreeView;
  8. import symantec.itools.awt.TreeNode;
  9. import symantec.itools.awt.LabelButton;
  10. import symantec.itools.multimedia.SlideShow;
  11. import symantec.itools.awt.ImageButton;
  12. import symantec.itools.awt.shape.Rect;
  13. import symantec.itools.multimedia.ImageViewer;
  14. import com.sun.java.swing.JLabel;
  15. public class TreeViewApplet extends Applet
  16. {
  17.     public void init()
  18.     {
  19.         // Take out this line if you don't use symantec.itools.net.RelativeURL or symantec.itools.awt.util.StatusScroller
  20.         symantec.itools.lang.Context.setApplet(this);
  21.     
  22.         // This code is automatically generated by Visual Cafe when you add
  23.         // components to the visual environment. It instantiates and initializes
  24.         // the components. To modify the code, only use code syntax that matches
  25.         // what Visual Cafe can generate, or Visual Cafe may be unable to back
  26.         // parse your Java file into its visual environment.
  27.         //{{INIT_CONTROLS
  28.         setLayout(new BorderLayout(0,0));
  29.         setBackground(java.awt.Color.magenta);
  30.         setFont(new Font("Dialog", Font.BOLD, 12));
  31.         setSize(709,371);
  32.         panel1.setLayout(new GridLayout(1,3,0,0));
  33.         add(panel1);
  34.         panel1.setBackground(java.awt.Color.darkGray);
  35.         panel1.setBounds(0,0,709,371);
  36.         panel2.setLayout(new GridBagLayout());
  37.         panel1.add(panel2);
  38.         panel2.setBounds(0,0,236,371);
  39.         panel9.setLayout(new GridBagLayout());
  40.         panel2.add(panel9, new com.symantec.itools.awt.GridBagConstraintsD(0,0,1,1,1.0,1.0,java.awt.GridBagConstraints.CENTER,java.awt.GridBagConstraints.BOTH,new Insets(5,5,5,5),0,0));
  41.         panel9.setBackground(java.awt.Color.magenta);
  42.         panel9.setBounds(5,5,226,361);
  43.         {
  44.             String[] tempString = new String[1];
  45.             tempString[0] = "root";
  46.             treeView1.setTreeStructure(tempString);
  47.         }
  48.         panel9.add(treeView1, new com.symantec.itools.awt.GridBagConstraintsD(0,0,1,1,1.0,1.0,java.awt.GridBagConstraints.CENTER,java.awt.GridBagConstraints.BOTH,new Insets(0,0,0,0),0,0));
  49.         treeView1.setBackground(java.awt.Color.white);
  50.         treeView1.setForeground(java.awt.Color.black);
  51.         treeView1.setFont(new Font("Dialog", Font.PLAIN, 12));
  52.         treeView1.setBounds(0,0,226,361);
  53.         panel10.setLayout(new GridBagLayout());
  54.         panel1.add(panel10);
  55.         panel10.setBounds(236,0,236,371);
  56.         panel3.setLayout(new GridBagLayout());
  57.         panel10.add(panel3, new com.symantec.itools.awt.GridBagConstraintsD(0,0,1,1,1.0,1.0,java.awt.GridBagConstraints.CENTER,java.awt.GridBagConstraints.BOTH,new Insets(5,0,5,5),0,0));
  58.         panel3.setBackground(java.awt.Color.white);
  59.         panel3.setBounds(0,5,231,361);
  60.         label3.setText("    Insert a node with the following name");
  61.         panel3.add(label3, new com.symantec.itools.awt.GridBagConstraintsD(0,0,1,1,1.0,1.0,java.awt.GridBagConstraints.CENTER,java.awt.GridBagConstraints.NONE,new Insets(0,0,0,0),0,0));
  62.         label3.setFont(new Font("Dialog", Font.PLAIN, 12));
  63.         label3.setBounds(0,9,230,23);
  64.         panel3.add(textFieldInsert, new com.symantec.itools.awt.GridBagConstraintsD(0,1,1,1,1.0,1.0,java.awt.GridBagConstraints.CENTER,java.awt.GridBagConstraints.HORIZONTAL,new Insets(0,5,0,5),0,0));
  65.         textFieldInsert.setFont(new Font("Dialog", Font.PLAIN, 12));
  66.         textFieldInsert.setBounds(5,48,221,23);
  67.         panel6.setLayout(new GridBagLayout());
  68.         panel3.add(panel6, new com.symantec.itools.awt.GridBagConstraintsD(0,2,1,1,1.0,1.0,java.awt.GridBagConstraints.CENTER,java.awt.GridBagConstraints.BOTH,new Insets(0,0,0,0),0,0));
  69.         panel6.setBounds(0,79,231,85);
  70.         label2.setText("  as the:");
  71.         panel6.add(label2, new com.symantec.itools.awt.GridBagConstraintsD(0,0,1,1,1.0,1.0,java.awt.GridBagConstraints.CENTER,java.awt.GridBagConstraints.NONE,new Insets(0,0,0,0),0,0));
  72.         label2.setFont(new Font("Dialog", Font.PLAIN, 12));
  73.         label2.setBounds(20,2,57,23);
  74.         radioButtonChild.setState(true);
  75.         radioButtonChild.setLabel("child");
  76.         panel6.add(radioButtonChild, new com.symantec.itools.awt.GridBagConstraintsD(1,0,1,1,1.0,1.0,java.awt.GridBagConstraints.WEST,java.awt.GridBagConstraints.NONE,new Insets(0,0,0,0),0,0));
  77.         radioButtonChild.setFont(new Font("Dialog", Font.PLAIN, 12));
  78.         radioButtonChild.setBounds(98,2,56,23);
  79.         radioButtonLast.setLabel("last sibling");
  80.         panel6.add(radioButtonLast, new com.symantec.itools.awt.GridBagConstraintsD(1,2,1,1,1.0,1.0,java.awt.GridBagConstraints.WEST,java.awt.GridBagConstraints.NONE,new Insets(0,0,0,0),0,0));
  81.         radioButtonLast.setFont(new Font("Dialog", Font.PLAIN, 12));
  82.         radioButtonLast.setBounds(98,58,90,23);
  83.         radioButtonNext.setLabel("next sibling");
  84.         panel6.add(radioButtonNext, new com.symantec.itools.awt.GridBagConstraintsD(1,1,1,1,1.0,1.0,java.awt.GridBagConstraints.WEST,java.awt.GridBagConstraints.NONE,new Insets(0,0,0,0),0,0));
  85.         radioButtonNext.setFont(new Font("Dialog", Font.PLAIN, 12));
  86.         radioButtonNext.setBounds(98,30,92,23);
  87.         label1.setText("    of the currently selected node");
  88.         panel3.add(label1, new com.symantec.itools.awt.GridBagConstraintsD(0,5,1,1,1.0,1.0,java.awt.GridBagConstraints.CENTER,java.awt.GridBagConstraints.NONE,new Insets(0,12,0,0),0,0));
  89.         label1.setFont(new Font("Dialog", Font.PLAIN, 12));
  90.         label1.setBounds(28,172,186,23);
  91.         label4.setText("      The new node will use");
  92.         panel3.add(label4, new com.symantec.itools.awt.GridBagConstraintsD(0,6,1,1,1.0,1.0,java.awt.GridBagConstraints.CENTER,java.awt.GridBagConstraints.NONE,new Insets(0,0,0,0),0,0));
  93.         label4.setFont(new Font("Dialog", Font.PLAIN, 12));
  94.         label4.setBounds(38,211,155,23);
  95.         panel5.setLayout(new GridBagLayout());
  96.         panel3.add(panel5, new com.symantec.itools.awt.GridBagConstraintsD(0,7,1,1,1.0,1.0,java.awt.GridBagConstraints.CENTER,java.awt.GridBagConstraints.BOTH,new Insets(0,0,0,0),0,0));
  97.         panel5.setBounds(0,242,231,39);
  98.         buttonPrevious.setLabel("Prev.");
  99.         buttonPrevious.setEnabled(false);
  100.         panel5.add(buttonPrevious, new com.symantec.itools.awt.GridBagConstraintsD(0,0,1,1,1.0,1.0,java.awt.GridBagConstraints.CENTER,java.awt.GridBagConstraints.HORIZONTAL,new Insets(0,5,0,0),0,0));
  101.         buttonPrevious.setBackground(java.awt.Color.lightGray);
  102.         buttonPrevious.setForeground(java.awt.Color.blue);
  103.         buttonPrevious.setFont(new Font("Dialog", Font.BOLD, 12));
  104.         buttonPrevious.setBounds(6,8,72,23);
  105.         try
  106.         {
  107.             slideShow1.addImageAndDescription(symantec.itools.net.RelativeURL.getURL("arrowclosed.gif"),"");
  108.             slideShow1.addImageAndDescription(symantec.itools.net.RelativeURL.getURL("circleclosed.gif"),"");
  109.             slideShow1.addImageAndDescription(symantec.itools.net.RelativeURL.getURL("folderclosed.gif"),"");
  110.             slideShow1.addImageAndDescription(symantec.itools.net.RelativeURL.getURL("defaultclosed.gif"),"");
  111.         }
  112.         catch (java.net.MalformedURLException error) { }
  113.         panel5.add(slideShow1, new com.symantec.itools.awt.GridBagConstraintsD(1,0,1,1,1.0,1.0,java.awt.GridBagConstraints.EAST,java.awt.GridBagConstraints.NONE,new Insets(0,0,0,0),0,0));
  114.         slideShow1.setBounds(107,14,10,10);
  115.         try
  116.         {
  117.             slideShow2.addImageAndDescription(symantec.itools.net.RelativeURL.getURL("arrowopened.gif"),"");
  118.             slideShow2.addImageAndDescription(symantec.itools.net.RelativeURL.getURL("circleopened.gif"),"");
  119.             slideShow2.addImageAndDescription(symantec.itools.net.RelativeURL.getURL("folderopened.gif"),"");
  120.             slideShow2.addImageAndDescription(symantec.itools.net.RelativeURL.getURL("defaultopened.gif"),"");
  121.         }
  122.         catch (java.net.MalformedURLException error) { }
  123.         panel5.add(slideShow2, new com.symantec.itools.awt.GridBagConstraintsD(2,0,1,1,1.0,1.0,java.awt.GridBagConstraints.WEST,java.awt.GridBagConstraints.NONE,new Insets(0,0,0,0),0,0));
  124.         slideShow2.setBounds(117,14,10,10);
  125.         buttonNext.setLabel("Next");
  126.         panel5.add(buttonNext, new com.symantec.itools.awt.GridBagConstraintsD(3,0,1,1,1.0,1.0,java.awt.GridBagConstraints.CENTER,java.awt.GridBagConstraints.HORIZONTAL,new Insets(0,0,0,5),0,0));
  127.         buttonNext.setBackground(java.awt.Color.lightGray);
  128.         buttonNext.setForeground(java.awt.Color.blue);
  129.         buttonNext.setFont(new Font("Dialog", Font.BOLD, 12));
  130.         buttonNext.setBounds(156,8,69,23);
  131.         label5.setText("     as its images");
  132.         panel3.add(label5, new com.symantec.itools.awt.GridBagConstraintsD(0,8,1,1,1.0,1.0,java.awt.GridBagConstraints.CENTER,java.awt.GridBagConstraints.NONE,new Insets(0,0,0,0),0,0));
  133.         label5.setFont(new Font("Dialog", Font.PLAIN, 12));
  134.         label5.setBounds(63,289,104,23);
  135.         buttonInsert.setLabel("Insert");
  136.         panel3.add(buttonInsert, new com.symantec.itools.awt.GridBagConstraintsD(0,9,1,1,1.0,1.0,java.awt.GridBagConstraints.CENTER,java.awt.GridBagConstraints.HORIZONTAL,new Insets(0,5,0,5),0,0));
  137.         buttonInsert.setBackground(java.awt.Color.lightGray);
  138.         buttonInsert.setForeground(java.awt.Color.blue);
  139.         buttonInsert.setFont(new Font("Dialog", Font.BOLD, 12));
  140.         buttonInsert.setBounds(5,328,221,23);
  141.         panel4.setLayout(new GridBagLayout());
  142.         panel1.add(panel4);
  143.         panel4.setBounds(472,0,236,371);
  144.         panel11.setLayout(new GridBagLayout());
  145.         panel4.add(panel11, new com.symantec.itools.awt.GridBagConstraintsD(0,0,1,1,1.0,1.0,java.awt.GridBagConstraints.CENTER,java.awt.GridBagConstraints.BOTH,new Insets(5,0,0,5),0,0));
  146.         panel11.setBackground(java.awt.Color.white);
  147.         panel11.setBounds(0,6,231,102);
  148.         panel7.setLayout(new GridBagLayout());
  149.         panel11.add(panel7, new com.symantec.itools.awt.GridBagConstraintsD(0,0,1,1,1.0,1.0,java.awt.GridBagConstraints.CENTER,java.awt.GridBagConstraints.BOTH,new Insets(0,5,0,5),0,0));
  150.         panel7.setBounds(5,0,221,102);
  151.         panel8.setLayout(new GridBagLayout());
  152.         panel7.add(panel8, new com.symantec.itools.awt.GridBagConstraintsD(0,0,1,2,1.0,1.0,java.awt.GridBagConstraints.CENTER,java.awt.GridBagConstraints.BOTH,new Insets(0,0,0,0),0,0));
  153.         panel8.setBounds(0,0,69,102);
  154.         label8.setText("tree color");
  155.         panel8.add(label8, new com.symantec.itools.awt.GridBagConstraintsD(0,0,1,1,1.0,1.0,java.awt.GridBagConstraints.WEST,java.awt.GridBagConstraints.HORIZONTAL,new Insets(0,0,0,0),0,0));
  156.         label8.setFont(new Font("Dialog", Font.PLAIN, 12));
  157.         label8.setBounds(0,5,69,23);
  158.         label9.setText("status");
  159.         panel8.add(label9, new com.symantec.itools.awt.GridBagConstraintsD(0,1,1,1,1.0,1.0,java.awt.GridBagConstraints.WEST,java.awt.GridBagConstraints.HORIZONTAL,new Insets(0,0,0,0),0,0));
  160.         label9.setFont(new Font("Dialog", Font.PLAIN, 12));
  161.         label9.setBounds(0,39,69,23);
  162.         label7.setText("# nodes");
  163.         panel8.add(label7, new com.symantec.itools.awt.GridBagConstraintsD(0,2,1,1,1.0,1.0,java.awt.GridBagConstraints.WEST,java.awt.GridBagConstraints.HORIZONTAL,new Insets(0,0,0,0),0,0));
  164.         label7.setFont(new Font("Dialog", Font.PLAIN, 12));
  165.         label7.setBounds(0,73,69,23);
  166.         panel14.setLayout(new GridBagLayout());
  167.         panel7.add(panel14, new com.symantec.itools.awt.GridBagConstraintsD(1,0,1,1,10.0,1.0,java.awt.GridBagConstraints.CENTER,java.awt.GridBagConstraints.BOTH,new Insets(0,0,0,0),0,0));
  168.         panel14.setBounds(69,0,151,102);
  169.         choiceTreeColor.addItem("black");
  170.         choiceTreeColor.addItem("blue");
  171.         choiceTreeColor.addItem("red");
  172.         choiceTreeColor.addItem("green");
  173.         choiceTreeColor.addItem("yellow");
  174.         choiceTreeColor.addItem("orange");
  175.         choiceTreeColor.addItem("purple");
  176.         try {
  177.             choiceTreeColor.select(0);
  178.         }
  179.         catch (IllegalArgumentException e) { }
  180.         panel14.add(choiceTreeColor, new com.symantec.itools.awt.GridBagConstraintsD(0,0,1,1,1.0,1.0,java.awt.GridBagConstraints.CENTER,java.awt.GridBagConstraints.HORIZONTAL,new Insets(0,0,0,0),0,0));
  181.         choiceTreeColor.setFont(new Font("Dialog", Font.PLAIN, 12));
  182.         choiceTreeColor.setBounds(0,5,151,25);
  183.         textFieldStatus.setEditable(false);
  184.         textFieldStatus.setText("waiting for input");
  185.         panel14.add(textFieldStatus, new com.symantec.itools.awt.GridBagConstraintsD(0,1,1,1,1.0,1.0,java.awt.GridBagConstraints.CENTER,java.awt.GridBagConstraints.HORIZONTAL,new Insets(0,0,0,0),0,0));
  186.         textFieldStatus.setForeground(java.awt.Color.gray);
  187.         textFieldStatus.setFont(new Font("Dialog", Font.PLAIN, 12));
  188.         textFieldStatus.setBounds(0,40,151,23);
  189.         textFieldCount.setEditable(false);
  190.         textFieldCount.setText("1");
  191.         panel14.add(textFieldCount, new com.symantec.itools.awt.GridBagConstraintsD(0,2,1,1,1.0,1.0,java.awt.GridBagConstraints.CENTER,java.awt.GridBagConstraints.HORIZONTAL,new Insets(0,0,0,0),0,0));
  192.         textFieldCount.setForeground(java.awt.Color.gray);
  193.         textFieldCount.setFont(new Font("Dialog", Font.PLAIN, 12));
  194.         textFieldCount.setBounds(0,73,151,23);
  195.         panel15.setLayout(new GridBagLayout());
  196.         panel4.add(panel15, new com.symantec.itools.awt.GridBagConstraintsD(0,1,1,1,1.0,1.0,java.awt.GridBagConstraints.CENTER,java.awt.GridBagConstraints.BOTH,new Insets(5,0,5,5),0,0));
  197.         panel15.setBackground(java.awt.Color.white);
  198.         panel15.setBounds(0,113,231,64);
  199.         buttonNew.setLabel("Create New Tree");
  200.         panel15.add(buttonNew, new com.symantec.itools.awt.GridBagConstraintsD(0,0,1,1,1.0,1.0,java.awt.GridBagConstraints.CENTER,java.awt.GridBagConstraints.HORIZONTAL,new Insets(5,5,5,5),0,0));
  201.         buttonNew.setBackground(java.awt.Color.lightGray);
  202.         buttonNew.setForeground(new java.awt.Color(0,128,128));
  203.         buttonNew.setFont(new Font("Dialog", Font.BOLD, 12));
  204.         buttonNew.setBounds(5,20,221,23);
  205.         panel13.setLayout(new GridBagLayout());
  206.         panel4.add(panel13, new com.symantec.itools.awt.GridBagConstraintsD(0,2,1,1,1.0,1.0,java.awt.GridBagConstraints.CENTER,java.awt.GridBagConstraints.BOTH,new Insets(0,0,0,5),0,0));
  207.         panel13.setBackground(java.awt.Color.white);
  208.         panel13.setBounds(0,182,231,123);
  209.         label6.setText("   Delete the first node encountered");
  210.         panel13.add(label6, new com.symantec.itools.awt.GridBagConstraintsD(0,0,1,1,1.0,1.0,java.awt.GridBagConstraints.CENTER,java.awt.GridBagConstraints.NONE,new Insets(0,0,0,0),0,0));
  211.         label6.setFont(new Font("Dialog", Font.PLAIN, 12));
  212.         label6.setBounds(13,4,205,23);
  213.         label10.setText("   with the following name");
  214.         panel13.add(label10, new com.symantec.itools.awt.GridBagConstraintsD(0,1,1,1,1.0,1.0,java.awt.GridBagConstraints.CENTER,java.awt.GridBagConstraints.NONE,new Insets(0,0,0,0),0,0));
  215.         label10.setFont(new Font("Dialog", Font.PLAIN, 12));
  216.         label10.setBounds(39,34,152,23);
  217.         panel13.add(textFieldDelete, new com.symantec.itools.awt.GridBagConstraintsD(0,2,1,1,1.0,1.0,java.awt.GridBagConstraints.CENTER,java.awt.GridBagConstraints.HORIZONTAL,new Insets(0,5,0,5),0,0));
  218.         textFieldDelete.setFont(new Font("Dialog", Font.PLAIN, 12));
  219.         textFieldDelete.setBounds(5,64,221,23);
  220.         buttonDelete.setLabel("Delete");
  221.         panel13.add(buttonDelete, new com.symantec.itools.awt.GridBagConstraintsD(0,3,1,1,1.0,1.0,java.awt.GridBagConstraints.CENTER,java.awt.GridBagConstraints.HORIZONTAL,new Insets(0,5,0,5),0,0));
  222.         buttonDelete.setBackground(java.awt.Color.lightGray);
  223.         buttonDelete.setForeground(java.awt.Color.red);
  224.         buttonDelete.setFont(new Font("Dialog", Font.BOLD, 12));
  225.         buttonDelete.setBounds(5,94,221,23);
  226.         panel12.setLayout(new GridBagLayout());
  227.         panel4.add(panel12, new com.symantec.itools.awt.GridBagConstraintsD(0,3,1,1,1.0,1.0,java.awt.GridBagConstraints.CENTER,java.awt.GridBagConstraints.BOTH,new Insets(5,0,5,5),0,0));
  228.         panel12.setBackground(java.awt.Color.white);
  229.         panel12.setBounds(0,310,231,54);
  230.         buttonDeleteSelected.setLabel("Delete selected node");
  231.         panel12.add(buttonDeleteSelected, new com.symantec.itools.awt.GridBagConstraintsD(0,0,1,1,1.0,1.0,java.awt.GridBagConstraints.CENTER,java.awt.GridBagConstraints.HORIZONTAL,new Insets(0,5,0,5),0,0));
  232.         buttonDeleteSelected.setBackground(java.awt.Color.lightGray);
  233.         buttonDeleteSelected.setForeground(java.awt.Color.red);
  234.         buttonDeleteSelected.setFont(new Font("Dialog", Font.BOLD, 12));
  235.         buttonDeleteSelected.setBounds(5,15,221,23);
  236.         JLabel1.setText("jlabel");
  237.         add("Center",JLabel1);
  238.         JLabel1.setBounds(0,0,709,371);
  239.         //}}
  240.         
  241.         //INITIALIZE THE COUNTER FIELD: used to display the current number of
  242.         //nodes contained by the tree
  243.         textFieldCount.setText("" + treeView1.getCount());   
  244.  
  245.         //LOAD ALL OF THE IMAGES INTO THE APPLET'S MEMORY VIA A MEDIA TRACKER:  If 
  246.         //you don't do it this way, the images of each node will not show up the 
  247.         //first time they are drawn.
  248.         Image tempImage1 = this.getImage(this.getDocumentBase(), "arrowclosed.gif" );
  249.         Image tempImage2 = this.getImage(this.getDocumentBase(), "arrowopened.gif" );
  250.         Image tempImage3 = this.getImage(this.getDocumentBase(), "folderclosed.gif");
  251.         Image tempImage4 = this.getImage(this.getDocumentBase(), "folderopened.gif");
  252.         Image tempImage5 = this.getImage(this.getDocumentBase(), "circleclosed.gif");
  253.         Image tempImage6 = this.getImage(this.getDocumentBase(), "circleopened.gif");
  254.         
  255.         myImageLoader = new MediaTracker(treeView1);
  256.         try{
  257.             myImageLoader.addImage(tempImage1,1);
  258.             myImageLoader.addImage(tempImage2,1);
  259.             myImageLoader.addImage(tempImage3,1);
  260.             myImageLoader.addImage(tempImage4,1);
  261.             myImageLoader.addImage(tempImage5,1);
  262.             myImageLoader.addImage(tempImage6,1);
  263.             myImageLoader.waitForAll();
  264.         }catch (Exception e) {System.out.println(e);}
  265.  
  266.         //{{REGISTER_LISTENERS
  267.         SymAction lSymAction = new SymAction();
  268.         buttonDeleteSelected.addActionListener(lSymAction);
  269.         buttonDelete.addActionListener(lSymAction);
  270.         buttonInsert.addActionListener(lSymAction);
  271.         buttonNext.addActionListener(lSymAction);
  272.         buttonPrevious.addActionListener(lSymAction);
  273.         SymItem lSymItem = new SymItem();
  274.         choiceTreeColor.addItemListener(lSymItem);
  275.         buttonNew.addActionListener(lSymAction);
  276.         //}}
  277.     }
  278.     //{{DECLARE_CONTROLS
  279.     java.awt.Panel panel1 = new java.awt.Panel();
  280.     java.awt.Panel panel2 = new java.awt.Panel();
  281.     java.awt.Panel panel9 = new java.awt.Panel();
  282.     symantec.itools.awt.TreeView treeView1 = new symantec.itools.awt.TreeView();
  283.     java.awt.Panel panel10 = new java.awt.Panel();
  284.     java.awt.Panel panel3 = new java.awt.Panel();
  285.     java.awt.Label label3 = new java.awt.Label();
  286.     java.awt.TextField textFieldInsert = new java.awt.TextField();
  287.     java.awt.Panel panel6 = new java.awt.Panel();
  288.     java.awt.Label label2 = new java.awt.Label();
  289.     java.awt.Checkbox radioButtonChild = new java.awt.Checkbox();
  290.     java.awt.Checkbox radioButtonLast = new java.awt.Checkbox();
  291.     java.awt.Checkbox radioButtonNext = new java.awt.Checkbox();
  292.     java.awt.Label label1 = new java.awt.Label();
  293.     java.awt.Label label4 = new java.awt.Label();
  294.     java.awt.Panel panel5 = new java.awt.Panel();
  295.     java.awt.Button buttonPrevious = new java.awt.Button();
  296.     symantec.itools.multimedia.SlideShow slideShow1 = new symantec.itools.multimedia.SlideShow();
  297.     symantec.itools.multimedia.SlideShow slideShow2 = new symantec.itools.multimedia.SlideShow();
  298.     java.awt.Button buttonNext = new java.awt.Button();
  299.     java.awt.Label label5 = new java.awt.Label();
  300.     java.awt.Button buttonInsert = new java.awt.Button();
  301.     java.awt.Panel panel4 = new java.awt.Panel();
  302.     java.awt.Panel panel11 = new java.awt.Panel();
  303.     java.awt.Panel panel7 = new java.awt.Panel();
  304.     java.awt.Panel panel8 = new java.awt.Panel();
  305.     java.awt.Label label8 = new java.awt.Label();
  306.     java.awt.Label label9 = new java.awt.Label();
  307.     java.awt.Label label7 = new java.awt.Label();
  308.     java.awt.Panel panel14 = new java.awt.Panel();
  309.     java.awt.Choice choiceTreeColor = new java.awt.Choice();
  310.     java.awt.TextField textFieldStatus = new java.awt.TextField();
  311.     java.awt.TextField textFieldCount = new java.awt.TextField();
  312.     java.awt.Panel panel15 = new java.awt.Panel();
  313.     java.awt.Button buttonNew = new java.awt.Button();
  314.     java.awt.Panel panel13 = new java.awt.Panel();
  315.     java.awt.Label label6 = new java.awt.Label();
  316.     java.awt.Label label10 = new java.awt.Label();
  317.     java.awt.TextField textFieldDelete = new java.awt.TextField();
  318.     java.awt.Button buttonDelete = new java.awt.Button();
  319.     java.awt.Panel panel12 = new java.awt.Panel();
  320.     java.awt.Button buttonDeleteSelected = new java.awt.Button();
  321.     com.sun.java.swing.JLabel JLabel1 = new com.sun.java.swing.JLabel();
  322.     //}}
  323.     
  324.     //THE NEW NODE TO BE INSERTED
  325.     TreeNode newNode;
  326.     //THE CURRENTLY SELECTED NODE
  327.     TreeNode currentNode;
  328.     //THE OPEN AND CLOSED VIEW OF EACH IMAGE
  329.     Image  newNodeOpened, newNodeClosed;
  330.     String openedImageName, closedImageName;
  331.     //MEDIA TRACKER FOR LOADING IN IMAGES ON INITIALIZATION
  332.     MediaTracker myImageLoader;
  333.     
  334.     //BUTTONS: event handler code
  335.     class SymAction implements java.awt.event.ActionListener
  336.     {
  337.         public void actionPerformed(java.awt.event.ActionEvent event)
  338.         {
  339.             Object object = event.getSource();
  340.             if (object == buttonDeleteSelected)
  341.                 buttonDeleteSelected_Action(event);
  342.              else if (object == buttonDelete)
  343.                 buttonDelete_Action(event);
  344.              if (object == buttonInsert)
  345.                 buttonInsert_Action(event);
  346.             else if (object == buttonNext)
  347.                 buttonNext_Action(event);
  348.             else if (object == buttonPrevious)
  349.                 buttonPrevious_Action(event);
  350.             else if (object == buttonNew)
  351.                 buttonNew_Action(event);
  352.         }
  353.     }
  354.     //BUTTON DELETE SELECTED NODE IS CLICKED: Delete the currently
  355.     //selected node.
  356.      void buttonDeleteSelected_Action(java.awt.event.ActionEvent event)
  357.     {         
  358.        {     
  359.         buttonDeleteSelected_ActionPerformed_Interaction1(event);
  360.              
  361.         buttonDeleteSelected_ActionPerformed_Interaction2(event);
  362.              
  363.         buttonDeleteSelected_ActionPerformed_Interaction3(event);
  364.     }
  365.   }
  366.       //BUTTON DELETE (SPECIFIC NAMED NODE) IS CLICKED: Delete the node whose
  367.     //name matches that listed in the textFieldDelete text field.
  368.         void buttonDelete_Action(java.awt.event.ActionEvent event)    
  369.     {
  370.         buttonDelete_ActionPerformed_Interaction1(event);     
  371.              
  372.         buttonDelete_ActionPerformed_Interaction2(event);
  373.              
  374.         buttonDelete_ActionPerformed_Interaction3(event);
  375.         
  376.         //update the status field
  377.         textFieldStatus.setText("node deleted");
  378.         if (textFieldCount.getText().equals("0")){
  379.             textFieldStatus.setText("Press: Create New Tree");
  380.     }
  381.      
  382. }
  383.  
  384.  //BUTTON INSERT IS CLICKED: Insert a new node onto the tree
  385.     void buttonInsert_Action(java.awt.event.ActionEvent event)
  386.     {
  387.         //get the image
  388.         updateImage();
  389.         
  390.         newNodeClosed = this.getImage(this.getDocumentBase(), closedImageName);
  391.         newNodeOpened = this.getImage(this.getDocumentBase(), openedImageName);
  392.         
  393.         //get the position
  394.         int selectedRadioButton = 0;
  395.         if (radioButtonChild.getState() == true){ selectedRadioButton = 0; }
  396.         if (radioButtonNext.getState()  == true){ selectedRadioButton = 1; }
  397.         if (radioButtonLast.getState()  == true){ selectedRadioButton = 2; }
  398.  
  399.         //get the label
  400.         String newNodeText   = textFieldInsert.getText();
  401.     
  402.         //do the insert
  403.         newNode = new TreeNode(newNodeText, newNodeClosed, newNodeOpened, treeView1);
  404.         currentNode = treeView1.getSelectedNode();    
  405.         treeView1.insert(newNode, currentNode, selectedRadioButton);     
  406.         treeView1.redraw();
  407.         textFieldCount.setText("" + treeView1.getCount());
  408.         
  409.         //update the status field
  410.         textFieldStatus.setText("node inserted"); 
  411.                     
  412.     //    buttonInsert_ActionPerformed_Interaction1(event);
  413.     }
  414.     
  415.     //HELPER FUNCTION OF INSERT BUTTONS CODE: sets the image pointer
  416.     //used for the new node (openedImageName, closedImageName) to the 
  417.     //appropriat graphic.
  418.     //I also used this function to keep track of the previous and next
  419.     //button's enabled property.  It makes for a better UI to have them
  420.     //disabled when they can't do anything.
  421.     void updateImage()
  422.     {
  423.         int    selectedImage = slideShow1.getCurrentImageIndex();
  424.         
  425.         if (selectedImage == 0){
  426.             openedImageName = "arrowopened.gif";
  427.             closedImageName = "arrowclosed.gif";
  428.             
  429.             //disable the previous button for use
  430.             buttonPrevious.setEnabled(false);
  431.             
  432.         }else if (selectedImage == 1){
  433.             openedImageName = "circleopened.gif";
  434.             closedImageName = "circleclosed.gif";
  435.             
  436.             //enable the previous button for use
  437.             buttonPrevious.setEnabled(true);
  438.             
  439.         }else if (selectedImage == 2){
  440.             openedImageName = "folderopened.gif";
  441.             closedImageName = "folderclosed.gif";
  442.                         
  443.             //enable the next button for use
  444.             buttonNext.setEnabled(true);
  445.           
  446.         }else{
  447.             openedImageName = null;
  448.             closedImageName = null;
  449.             
  450.             //disable the next button for use
  451.             buttonNext.setEnabled(false);
  452.             
  453.         }
  454.     }
  455.  
  456.     //BUTTON NEXT IS CLICKED: go to the next option for
  457.     //node graphics in the slideShow component
  458.     void buttonNext_Action(java.awt.event.ActionEvent event)
  459.     {
  460.              
  461.         buttonNext_ActionPerformed_Interaction1(event);
  462.              
  463.         buttonNext_ActionPerformed_Interaction2(event);
  464.              
  465.         buttonNext_ActionPerformed_Interaction3(event);
  466.              
  467.         buttonNext_ActionPerformed_Interaction4(event);
  468.     }
  469.  
  470.     //BUTTON PREVIOUS IS CLICKED: go to the previous option for
  471.     //node graphics in the slideShow component
  472.     void buttonPrevious_Action(java.awt.event.ActionEvent event)
  473.     {
  474.              
  475.         buttonPrevious_ActionPerformed_Interaction1(event);
  476.              
  477.         buttonPrevious_ActionPerformed_Interaction2(event);
  478.              
  479.         buttonPrevious_ActionPerformed_Interaction3(event);
  480.              
  481.         buttonPrevious_ActionPerformed_Interaction4(event);
  482.     }
  483.  
  484.     //BUTTON NEW IS CLICKED:  Create a new tree
  485.     void buttonNew_Action(java.awt.event.ActionEvent event)
  486.     {
  487.              
  488.         buttonNew_ActionPerformed_Interaction1(event);
  489.              
  490.         buttonNew_ActionPerformed_Interaction2(event);
  491.              
  492.         buttonNew_ActionPerformed_Interaction3(event);
  493.     }
  494.  
  495.     //COLOR SELECTED FROM CHOICE BOX: event handler
  496.     class SymItem implements java.awt.event.ItemListener
  497.     {
  498.         public void itemStateChanged(java.awt.event.ItemEvent event)
  499.         {
  500.             Object object = event.getSource();
  501.             if (object == choiceTreeColor)
  502.                 choiceTreeColor_ItemStateChanged(event);
  503.         }
  504.     }
  505.  
  506.     //COLOR SELECTED FROM CHOICE BOX: select the color to display the tree in
  507.     void choiceTreeColor_ItemStateChanged(java.awt.event.ItemEvent event)
  508.     {
  509.              
  510.         choiceTreeColor_ItemStateChanged_Interaction1(event);
  511.     }
  512.  
  513.     void buttonDelete_ActionPerformed_Interaction1(java.awt.event.ActionEvent event)
  514.     {
  515.         try {
  516.             treeView1.remove(textFieldDelete.getText());
  517.         } catch (Exception e) {
  518.         }
  519.     }
  520.  
  521.     void buttonDelete_ActionPerformed_Interaction2(java.awt.event.ActionEvent event)
  522.     {
  523.         try {
  524.             treeView1.repaint();
  525.         } catch (Exception e) {
  526.         }
  527.     }
  528.  
  529.     void buttonDelete_ActionPerformed_Interaction3(java.awt.event.ActionEvent event)
  530.     {
  531.         try {
  532.             // convert int->class java.lang.String
  533.             textFieldCount.setText(java.lang.String.valueOf(treeView1.getCount()));
  534.         } catch (Exception e) {
  535.         }
  536.     }
  537.  
  538.     void buttonDeleteSelected_ActionPerformed_Interaction1(java.awt.event.ActionEvent event)
  539.     {
  540.         try {
  541.             treeView1.removeSelected();
  542.         } catch (Exception e) {
  543.         }
  544.     }
  545.  
  546.     void buttonDeleteSelected_ActionPerformed_Interaction2(java.awt.event.ActionEvent event)
  547.     {
  548.         try {
  549.             treeView1.repaint();
  550.         } catch (Exception e) {
  551.         }
  552.     }
  553.  
  554.         
  555.     void buttonNext_ActionPerformed_Interaction1(java.awt.event.ActionEvent event) {
  556.         try {
  557.             slideShow2.nextImage();
  558.         } catch (Exception e) {
  559.         }
  560.     }
  561.  
  562.     void buttonNext_ActionPerformed_Interaction2(java.awt.event.ActionEvent event) {
  563.         try {
  564.             slideShow1.nextImage();
  565.         } catch (Exception e) {
  566.         }
  567.     }
  568.  
  569.     void buttonNext_ActionPerformed_Interaction3(java.awt.event.ActionEvent event) {
  570.         try {
  571.     //        buttonNext.updateImage();
  572.         } catch (Exception e) {
  573.     
  574.         }
  575.     }
  576.  
  577.     void buttonPrevious_ActionPerformed_Interaction1(java.awt.event.ActionEvent event) {
  578.         try {
  579.             slideShow2.previousImage();
  580.         } catch (Exception e) {
  581.         }
  582.     }
  583.  
  584.     void buttonPrevious_ActionPerformed_Interaction2(java.awt.event.ActionEvent event) {
  585.         try {
  586.             slideShow1.previousImage();
  587.         } catch (Exception e) {
  588.         }
  589.     }
  590.  
  591.     void buttonPrevious_ActionPerformed_Interaction3(java.awt.event.ActionEvent event) {
  592.         try {
  593. //            buttonPrevious.update();
  594.         } catch (Exception e) {
  595.         }
  596.     }
  597.  
  598.     void buttonNext_ActionPerformed_Interaction4(java.awt.event.ActionEvent event) {
  599.         try {
  600.             textFieldStatus.setText("choosing image");
  601.         } catch (Exception e) {
  602.         }
  603.     }
  604.  
  605.     void buttonPrevious_ActionPerformed_Interaction4(java.awt.event.ActionEvent event) {
  606.         try {
  607.             textFieldStatus.setText("choosing image");
  608.         } catch (Exception e) {
  609.         }
  610.     }
  611.  
  612.     void buttonNew_ActionPerformed_Interaction1(java.awt.event.ActionEvent event) {
  613.         try {
  614.               java.lang.String[] tempString = new java.lang.String[1];
  615.               tempString[0] = new java.lang.String("root");
  616.               treeView1.setTreeStructure(tempString);
  617.         } catch (Exception e) {
  618.         }
  619.     }
  620.  
  621.     void buttonNew_ActionPerformed_Interaction2(java.awt.event.ActionEvent event) {
  622.         try {
  623.             textFieldCount.setText("" + treeView1.getCount());
  624.         } catch (Exception e) {
  625.         }
  626.     }
  627.  
  628.     void buttonNew_ActionPerformed_Interaction3(java.awt.event.ActionEvent event) {
  629.         try {
  630.             textFieldStatus.setText("new tree created");
  631.         } catch (Exception e) {
  632.         }
  633.     }
  634.  
  635.     void choiceTreeColor_ItemStateChanged_Interaction1(java.awt.event.ItemEvent event) {
  636.         try {
  637.                         String selectedColor = choiceTreeColor.getSelectedItem();    
  638.  
  639.         if      (selectedColor == "black" ) {treeView1.setForeground(Color.black)  ;}
  640.         else if (selectedColor == "blue"  ) {treeView1.setForeground(Color.blue)   ;}
  641.         else if (selectedColor == "red"   ) {treeView1.setForeground(Color.red)    ;}
  642.         else if (selectedColor == "green" ) {treeView1.setForeground(Color.green)  ;}
  643.         else if (selectedColor == "yellow") {treeView1.setForeground(Color.yellow) ;}
  644.         else if (selectedColor == "orange") {treeView1.setForeground(Color.orange );}
  645.         else if (selectedColor == "purple") {treeView1.setForeground(Color.magenta);}
  646.         treeView1.redraw();
  647.     
  648.         } catch (Exception e) {
  649.         }
  650.     }
  651.  
  652.     void buttonInsert_ActionPerformed_Interaction1(java.awt.event.ActionEvent event)
  653.     {
  654.         try {
  655.             treeView1.redraw();
  656.         } catch (Exception e) {
  657.         }
  658.     }
  659.  
  660.     void buttonDeleteSelected_ActionPerformed_Interaction3(java.awt.event.ActionEvent event)
  661.     {
  662.         try {
  663.             // treeView1 Get the string for the selected node
  664.             textFieldCount.setText(treeView1.getSelectedText());
  665.         } catch (Exception e) {
  666.         }
  667.     }
  668. }
  669.